package com.ider.deskcust;

import android.os.Parcel;
import android.os.Parcelable;
import org.json.JSONException;
import org.json.JSONObject;

/**
 * Created by ider-eric on 2016/5/23.
 * 此类实现了可序列化Parcelable接口
 */
public class TileEntry implements Parcelable {

    public String id;
    public String themecode;
    public String strucode;
    public String strutype;
    public String strutitle;
    public String strubg;
    public String parentstrucode;
    public String strucommand;
    public String strutext;
    public String appcode;
    public String apkaddress;
    public String struorder;
    public String ispush;
    public String strupic;
    public String iconbg;
    public String apppara;
    public String strucommand_web_para_ismac;
    public String stru;
    public TileEntry() {
    }

    public TileEntry(JSONObject json) {
        try {
            id = json.getString("id");
            themecode = json.getString("themecode");
            strucode = json.getString("strucode");
            strutype = json.getString("strutype");
            strutitle = json.getString("strutitle");
            strubg = json.getString("strubg");
            parentstrucode = json.getString("parentstrucode");
            strucommand = json.getString("strucommand");
            strutext = json.getString("strutext");
            appcode = json.getString("appcode");
            apkaddress = json.getString("apkaddress");
            struorder = json.getString("struorder");
            ispush = json.getString("ispush");
            strupic = json.getString("strupic");
            iconbg = json.getString("iconbg");
            apppara = json.getString("apppara");
            strucommand_web_para_ismac = json.getString("strucommand_web_para_ismac");
            stru = json.getString("stru");
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
    @Override
    public void writeToParcel(Parcel parcel, int flag) {

        parcel.writeString(id);
        parcel.writeString(themecode);
        parcel.writeString(strucode);
        parcel.writeString(strutype);
        parcel.writeString(strutitle);
        parcel.writeString(strubg);
        parcel.writeString(parentstrucode);
        parcel.writeString(strucommand);
        parcel.writeString(strutext);
        parcel.writeString(appcode);
        parcel.writeString(apkaddress);
        parcel.writeString(struorder);
        parcel.writeString(ispush);
        parcel.writeString(strupic);
        parcel.writeString(iconbg);
        parcel.writeString(apppara);
        parcel.writeString(strucommand_web_para_ismac);
        parcel.writeString(stru);

    }


    public static final Parcelable.Creator<TileEntry> CREATOR = new Parcelable.Creator<TileEntry>() {
        @Override
        public TileEntry createFromParcel(Parcel parcel) {
            TileEntry entry = new TileEntry();
            entry.id = parcel.readString();
            entry.themecode = parcel.readString();
            entry.strucode = parcel.readString();
            entry.strutype = parcel.readString();
            entry.strutitle = parcel.readString();
            entry.strubg = parcel.readString();
            entry.parentstrucode = parcel.readString();
            entry.strucommand = parcel.readString();
            entry.strutext = parcel.readString();
            entry.appcode = parcel.readString();
            entry.apkaddress = parcel.readString();
            entry.struorder = parcel.readString();
            entry.ispush = parcel.readString();
            entry.strupic = parcel.readString();
            entry.iconbg = parcel.readString();
            entry.apppara = parcel.readString();
            entry.strucommand_web_para_ismac = parcel.readString();
            entry.stru = parcel.readString();
            return entry;
        }

        @Override
        public TileEntry[] newArray(int i) {
            return new TileEntry[i];
        }
    };


    @Override
    public boolean equals(Object o) {
        TileEntry r = (TileEntry)o;
        return r.id.equals(id);
    }

    @Override
    public int describeContents() {
        return 0;
    }
}
